// pages/gy/gy.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    step: 0
  },
  onReady: function () {
    var that = this;
    var cxt = wx.createCanvasContext('canvasCircle');
    cxt.setLineWidth(6);
    cxt.setStrokeStyle('#eaeaea');
    cxt.setLineCap('round');
    cxt.beginPath();
    cxt.arc(80, 80, 65, 0, 2 * Math.PI, false);
    cxt.stroke();
    cxt.draw();
    //加载动画
    var steps = 1, startAngle = 1.5 * Math.PI, endAngle = 0, speed = 100, sec = 100;
    function drawing(s, e) {
      var context = wx.createCanvasContext('canvasRing');
      context.setLineWidth(6);
      context.setStrokeStyle('rgb(71, 197, 247)');
      context.setLineCap('round');
      context.beginPath();
      context.arc(80, 80, 65, s, e, false);
      context.stroke();
      context.draw();
    }
    function drawLoading() {
      if (steps < 101) {
        that.setData({
          step: steps
        })
        endAngle = steps * 2 * Math.PI / speed + startAngle;
        drawing(startAngle, endAngle);
        steps++;
      } else {
        clearInterval(this.interval);
      }
    }
    this.interval = setInterval(drawLoading, sec);
    setTimeout(function () {
    	wx.showToast({
        title: '挂釉完成！',
        icon:'success',
        duration:1000,
        success:function () {
          setTimeout(function () {
            wx.navigateTo({
              url: '../hh4/hh4',
            })
          },1000)
        }
    	})
    },10000)
  }
})